package com.useeinfo.oa.modules.inspection.entity;

import com.alibaba.fastjson.JSONObject;
import com.useeinfo.framework.extend.entity.SuperClassEntity;
import com.useeinfo.framework.sugar.tools.StringConverters;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * 巡检模块设备和工艺的关联表快照——管理工单
 */
@Entity
@Table(name = "facility_inspection_snap")
public class FacilityInspectionSnap extends SuperClassEntity<FacilityInspectionSnap> {
    /**
     * 工单
     */
    @ManyToOne
    @JoinColumn(name = "inspectionOrder_id")
    private InspectionOrder inspectionOrder;


    public String getOrderCode() {
        return orderCode;
    }

    public void setOrderCode(String orderCode) {
        this.orderCode = orderCode;
    }

    @Column(columnDefinition = "bit default 0")
    private boolean completed;
    /**
     * 工单号
     */
    private String orderCode;
    /**
     * 设备id
     */
    private Long facilityId;
    /**
     * 设备编号
     */
    private String facilityCode;

    /**
     * 设备名称
     */
    private String facilityName;
    /**
     * 设备区域id
     */
    private Long areaId;
    /**
     * 设备区域名称
     */
    private String areaName;
    /**
     * 类型
     */
    private Long facilityCatId;
    /**
     * 类型名称
     */
    private String facilityCatName;
    /**
     * 专业
     */
    private Long rootCatId;
    /**
     * 专业名称
     */
    private String rootCatName;
    /**
     * 设备位置
     */
    private String position;
    /**
     * 设备具体位置
     */
    private String precisePosition;
    /**
     * 铭牌照片
     */
    private String platePhotoPath;
    /**
     * 现场照片
     */
    private String fieldPhotoPath;

    /**
     * 设备分组名称
     */
    private Long facilityGroupId;
    /**
     * 设备所属分组名称
     */
    private String facilityGroupName;
    /**
     * 设备分组编号
     */
    private String facilityGroupCode;
    /**
     * 二维码值
     */
    private String QRCode;

    /**
     * 工艺id
     */
    private Long inspectionId;

    /**
     * 工艺名称
     */

    private String inspectionName;
    /**
     * 默认应用场景ID
     */
    private Long applicationScenariosId;
    /**
     * 规格型号
     */
    private String spec;
    /**
     * 安全要求
     */
    private String safety;
    /**
     * 是否异常
     */
    @Column(columnDefinition = "bit default 0")
    private boolean abnormal;


    /**
     * 是否临时数据
     *
     * @return
     */
    private Boolean tempVal = true;

    /**
     * 工单流水号(临时储存用)
     */
    private String serial;

    /**
     * 关联申请记录
     */
    @OneToMany(mappedBy = "facilityInspectionSnap",fetch = FetchType.LAZY)
    private Set<InspectionOrderWorkContent> inspectionOrderWorkContents = new HashSet<>();

    public Long getFacilityId() {
        return facilityId;
    }

    public void setFacilityId(Long facilityId) {
        this.facilityId = facilityId;
    }

    public String getFacilityCode() {
        return facilityCode;
    }

    public void setFacilityCode(String facilityCode) {
        this.facilityCode = facilityCode;
    }

    public String getFacilityName() {
        return facilityName;
    }

    public void setFacilityName(String facilityName) {
        this.facilityName = facilityName;
    }

    public String getSpec() {
        return spec;
    }

    public void setSpec(String spec) {
        this.spec = spec;
    }

    public Long getFacilityGroupId() {
        return facilityGroupId;
    }

    public void setFacilityGroupId(Long facilityGroupId) {
        this.facilityGroupId = facilityGroupId;
    }

    public String getFacilityGroupName() {
        return facilityGroupName;
    }

    public void setFacilityGroupName(String facilityGroupName) {
        this.facilityGroupName = facilityGroupName;
    }

    public String getFacilityGroupCode() {
        return facilityGroupCode;
    }

    public void setFacilityGroupCode(String facilityGroupCode) {
        this.facilityGroupCode = facilityGroupCode;
    }

    public Long getInspectionId() {
        return inspectionId;
    }

    public void setInspectionId(Long inspectionId) {
        this.inspectionId = inspectionId;
    }

    public String getInspectionName() {
        return inspectionName;
    }

    public void setInspectionName(String inspectionName) {
        this.inspectionName = inspectionName;
    }

    public Long getAreaId() {
        return areaId;
    }

    public void setAreaId(Long areaId) {
        this.areaId = areaId;
    }

    public String getAreaName() {
        return areaName;
    }

    public void setAreaName(String areaName) {
        this.areaName = areaName;
    }

    public Long getFacilityCatId() {
        return facilityCatId;
    }

    public void setFacilityCatId(Long facilityCatId) {
        this.facilityCatId = facilityCatId;
    }

    public String getFacilityCatName() {
        return facilityCatName;
    }

    public void setFacilityCatName(String facilityCatName) {
        this.facilityCatName = facilityCatName;
    }

    public String getQRCode() {
        return QRCode;
    }

    public void setQRCode(String QRCode) {
        this.QRCode = QRCode;
    }

    public Boolean getTempVal() {
        return tempVal;
    }

    public void setTempVal(Boolean tempVal) {
        this.tempVal = tempVal;
    }

    public String getSerial() {
        return serial;
    }

    public void setSerial(String serial) {
        this.serial = serial;
    }

    public Long getRootCatId() {
        return rootCatId;
    }

    public void setRootCatId(Long rootCatId) {
        this.rootCatId = rootCatId;
    }

    public String getRootCatName() {
        return rootCatName;
    }

    public void setRootCatName(String rootCatName) {
        this.rootCatName = rootCatName;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public String getPrecisePosition() {
        return precisePosition;
    }

    public void setPrecisePosition(String precisePosition) {
        this.precisePosition = precisePosition;
    }

    public String getPlatePhotoPath() {
        return platePhotoPath;
    }

    public void setPlatePhotoPath(String platePhotoPath) {
        this.platePhotoPath = platePhotoPath;
    }

    public String getFieldPhotoPath() {
        return fieldPhotoPath;
    }

    public void setFieldPhotoPath(String fieldPhotoPath) {
        this.fieldPhotoPath = fieldPhotoPath;
    }

    public boolean isCompleted() {
        return completed;
    }

    public void setCompleted(boolean completed) {
        this.completed = completed;
    }

    public String getSafety() {
        return safety;
    }

    public void setSafety(String safety) {
        this.safety = safety;
    }

    public InspectionOrder getInspectionOrder() {
        return inspectionOrder;
    }

    public void setInspectionOrder(InspectionOrder inspectionOrder) {
        this.inspectionOrder = inspectionOrder;
    }

    public Set<InspectionOrderWorkContent> getInspectionOrderWorkContents() {
        return inspectionOrderWorkContents;
    }

    public void setInspectionOrderWorkContents(Set<InspectionOrderWorkContent> inspectionOrderWorkContents) {
        this.inspectionOrderWorkContents = inspectionOrderWorkContents;
    }

    public boolean isAbnormal() {
        return abnormal;
    }

    public void setAbnormal(boolean abnormal) {
        this.abnormal = abnormal;
    }

    public Long getApplicationScenariosId() {
        return applicationScenariosId;
    }

    public void setApplicationScenariosId(Long applicationScenariosId) {
        this.applicationScenariosId = applicationScenariosId;
    }

    @Override
    public JSONObject toJSONObject() {
        JSONObject jsonObject = super.toJSONObject();
        jsonObject.put("facilityName", StringConverters.null2String(getFacilityName()));
        jsonObject.put("facilityCode", StringConverters.null2String(getFacilityCode()));
        jsonObject.put("facilityId", StringConverters.null2String(getFacilityId()));
        jsonObject.put("inspectionId", StringConverters.null2String(getInspectionId()));
        jsonObject.put("inspectionName", StringConverters.null2String(getInspectionName()));
        jsonObject.put("spec", StringConverters.null2String(getSpec()));
        jsonObject.put("safety", StringConverters.null2String(getSafety()));
        jsonObject.put("orderCode", StringConverters.null2String(getOrderCode()));
        jsonObject.put("completed", StringConverters.null2Boolean(isCompleted()));
        jsonObject.put("facilityCatName", StringConverters.null2String(getFacilityCatName()));
        jsonObject.put("facilityCatId", StringConverters.null2String(getFacilityCatId()));
        return jsonObject;
    }
}
